<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/main.css" rel="stylesheet" />
	</head>
	<body>
	<header class="mui-bar mui-bar-nav" id="head">
		<p class=" mui-pull-left" id="back"><a href="javascript:history.go(-1)">退出</a></p>
		<h1 class="mui-title">通讯录</h1>
		<p class=" mui-pull-right" id="admin"></p>
	</header>
	<form class="mui-input-group">
	    <div class="mui-input-row mui-search">
		    <input type="search" class="mui-input-clear" placeholder="">
		</div>
	</form>
	<div class="mui-content">
		<div class="mui-content-padded">
			<ul class="mui-table-view" id="contacts">
			</ul>
		</div>
	</div>
	<script src="js/mui.min.js"></script>
	<script src="js/app.js"></script>
	<script>
		var admin = document.getElementById("admin");
		var contacts = document.getElementById("contacts");
		var url = decodeURI(decodeURI(window.location.href));
		var urlArr=url.split("?");
		var info = urlArr[urlArr.length-1];
		var infoARrr = info.split("&");
		var name = infoARrr[0].split("=")[1];
		var deptId = infoARrr[1].split("=")[1];
//			console.log(name);console.log(deptId);
		admin.innerHTML = name;
		function getXMLHttpRequest() {  
		    var xhr;  
		    try {  
		        xhr = new XMLHttpRequest();  
		    } catch (err1) {  
		        try {  
		            xhr = new ActiveXObject("Microsoft.XMLHTTP");  
		        } catch (err2) {  
		            alert("您的浏览器版本不支持Ajax....");  
		        }  
		    }  
		    return xhr;  
		}
		function saxJson() {
			
		    var xhr = getXMLHttpRequest();  
		    xhr.open("GET", "API/Data/empl.json", true);  
		    xhr.send();  
		    xhr.onreadystatechange = function() {  
		        if (xhr.readyState == 4 && xhr.status == 200) {
		        	var i=0,str="";
		        	var Empls = eval("(" + xhr.responseText + ")").Empls;
		        	var len = Empls.length;
					for(;i<len;i++){
						if(deptId==Empls[i].DeptID){
							str+="<li class='mui-table-view-cell'><a href='detal.html?ID="
							+encodeURI(encodeURI(Empls[i].ID))+"&DeptID="+encodeURI(encodeURI(Empls[i].DeptID))+"'>"
							+Empls[i].Name+
							"</a></li>";
						}
					}
					contacts.innerHTML=str;
					
		        }  
		    }
		} 
		saxJson();
		
		mui.init();
		mui.plusReady(function() {
			mui.back = function(event) {
				window.history.go(-1);
			};
		});

	</script>
</body>

</html>